package com.aaa.hospital.controller;

import com.aaa.hospital.util.SOSSUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author: Guaniu
 * @Date: 2022/2/17 8:50
 * @Version 1.0
 */
@RequestMapping("upload")
@RestController
public class UploadController {
    @Autowired
    private SOSSUtil sossUtil;
    @RequestMapping("file")
    public Map<String,Object> upload (@RequestParam("file") MultipartFile multipartFile, HttpServletRequest request) {
        String dir = request.getParameter("dir");
        Map<String,Object> map = new HashMap<>();
        map.put("url",sossUtil.uploadfile(multipartFile,dir));
        return map;
    }
}
